#pragma once
#include <memory>
#include <boost/signals2.hpp>
#include <SFML/Graphics/Color.hpp>
#include <nice2d/sprite.h>
#include <nice2d/component.h>
#include <nice2d/serializer.h>
#include <nice2d/piece/factioncontroller.h>

class Faction : public Serializer
{
    friend class FactionManager;
public:
    Faction() = delete;
    Faction(const sf::Color &color, const std::wstring &name, const std::wstring &desc = std::wstring());
    ~Faction();
public:
    std::wstring getName()const;
    std::wstring getDescription()const;
    sf::Color getColor()const;

    void formAlliance(std::shared_ptr<Faction> other, bool alliance = true);
    bool isAllied(const sf::Color &color);

    void setFactionController(std::shared_ptr<FactionController> controller);
    std::shared_ptr<FactionController> getFactionController()const;
public:
    PTree serialize() override;
    void deserialize(const PTree &mode) override;
private:
    std::unique_ptr<class FactionData> data;
};

using FactionPointer = std::shared_ptr<Faction>;
